package com.todo.biz.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.biz.application.frontend.service.FeedbackAggService;
import com.todo.biz.iface.frontend.FeedbackFrontendIface;
import com.todo.biz.iface.frontend.request.*;
import com.todo.biz.iface.frontend.response.FeedbackBaseVO;
import com.todo.biz.iface.frontend.response.FeedbackDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/28 14:37
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/bizBase/feedback")
@Tag(name = "反馈前台接口", description = "反馈前台接口")
public class FeedbackFrontendController implements FeedbackFrontendIface {

    @Resource
    private FeedbackAggService feedbackAggService;

    @Override
    @Operation(summary = "新增反馈信息")
    @PostMapping("/insertFeedback")
    public BizResponse<Boolean> insertFeedback(@RequestBody InsertFeedbackParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return feedbackAggService.insertFeedback(param);
    }

    @Override
    @Operation(summary = "删除反馈信息")
    @PostMapping("/removeFeedback")
    public BizResponse<Boolean> removeFeedback(@RequestBody RemoveFeedbackParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return feedbackAggService.removeFeedback(param);
    }

    @Override
    @Operation(summary = "更新反馈信息")
    @PostMapping("/updateFeedback")
    public BizResponse<Boolean> updateFeedback(@RequestBody UpdateFeedbackParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return feedbackAggService.updateFeedback(param);
    }

    @Override
    @Operation(summary = "根据主键查询反馈详情")
    @PostMapping("/queryFeedbackById")
    public BizResponse<FeedbackDetailVO> queryFeedbackById(@RequestBody QueryFeedbackByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return feedbackAggService.queryFeedbackById(param);
    }

    @Override
    @Operation(summary = "根据用户查询反馈列表")
    @PostMapping("/queryContentClassifyList")
    public BizPageResponse<FeedbackBaseVO> queryFeedbackByUserId(@RequestBody QueryFeedbackByUserIdParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return feedbackAggService.queryFeedbackByUserId(param);
    }
}
